package com.study.sms.config;

import com.study.sms.client.SmsClientFactory;
import com.study.sms.client.SmsClientFactoryImpl;
import com.study.sms.properties.SmsProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 短信配置类
 *
 * @author nizhihao
 * @version 1.0.0
 * @date 2022/8/22 22:34
 */
@Configuration
public class SmsConfig {

    @Bean
    @ConditionalOnProperty(value = "sms.enabled", havingValue = "true")
    public SmsClientFactory smsClientFactory(SmsProperties smsProperties) {
        return new SmsClientFactoryImpl(smsProperties);
    }

}
